<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var arr=["b", "c","b", "c","a", "b", "c"] 

    var obj=arr.reduce((newObj,item)=>{
        // 创建一个空对象newObj 
        if(newObj[item]){ // 如果属性存在则值加1
            newObj[item]++
        }else{
            newObj[item]=1 // 不存在则等于1 最开始是空对象 所以
        }                   // 当a、b、c各自第一次执行判断时都为1
        return newObj
    },{})
  
    console.log(obj);
</script>
</html>